package com.huakang.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

/**
 * @Author{小熊}
 * @Date2025/1/14 10:23
 */
@RestController
public class UploadController {
    @PostMapping("/upload")
    public String upload(MultipartFile file){
        String filename = file.getOriginalFilename();
        String s = filename.substring(filename.lastIndexOf("."));
        filename = UUID.randomUUID()+s;
        try {
            file.transferTo(new File("D:\\XNWN\\file\\"+filename));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return "ok";
    }
}
